package com.jbp.controller;

import com.jbp.model.InviteReward;
import com.jbp.service.InviteRewardService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 推广奖励(InviteReward)表控制层
 * @author cc
 * @since 2020-07-26 13:53:10
 */
@Api(tags ="APP接口--邀请好友" ,hidden = true)
@ApiIgnore
@RestController
@RequestMapping("rest/inviteReward")
public class InviteRewardController {
    @Autowired
    private InviteRewardService inviteRewardService;

    /** 列表 */
    @ApiOperation(value="推广列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = InviteReward.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params, @RequestAttribute("userId") Integer userId){
        params.put("userId", userId);
        PageUtils page = inviteRewardService.queryPage(params);
        return R.ok(page);
    }

    @ApiOperation(value="信息")
    @GetMapping("/info")
    public R info(@RequestAttribute("userId") Integer userId){
        Map<String, Object> map = inviteRewardService.info(userId);
        return R.ok(map);
    }

    @ApiOperation(value="提取待发奖励")
    @GetMapping("/extract")
    public R extract(@RequestAttribute("userId") Integer userId){
        inviteRewardService.extract(userId);
        return R.ok();
    }

}